package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.dto.PasswordEditDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface EmployeeMapper {

    /**
     * 登录
     * @param username 用户名
     * @return Employee
     */

    @Select("select * from employee where username=#{username}")
    Employee login(String username);

    /**
     * 修改密码
     * @param passwordEditDTO 条件
     */
    void updatePassword(PasswordEditDTO passwordEditDTO);

    /**
     * 启用/修改员工账号
     * @param status 员工
     */
    @Update("update employee set status=#{status} where id=#{id}")
    void updateStatus(Integer status,Integer id);

    /**
     * 员工分页查询
     * @param employeePageQueryDTO 条件
     * @return PageBean
     */
    Page pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 新增员工
     * @param employee 员工信息
     */
    @AutoFill(value = OperationType.INSERT)
    void add(Employee employee);

    /**
     * 根据id查询
     * @param id 主键
     * @return Employee
     */
    @Select("select * from employee where id=#{id}")
    Employee selectById(Integer id);

    /**
     * 修改员工信息
     * @param employee 员工信息
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateEmployee(Employee employee);
}
